#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstdint>

using namespace std;

class Solution {
public:
    string countAndSay(int n) {
        string str;
        str = "1";
        if (n <= 1){
            return str;
        }
        for (int i = 2; i <= n; i++){
            string temp;
            int cnt = 0;
            for (int j = 0; j < str.length(); j++){
                cnt++;
                if (j+1 == str.length() || str[j+1] != str[j]){
                    char buf[32] = {0};
                    sprintf(buf, "%d", cnt);
                    temp += buf;
                    temp += str[j];
                    cnt = 0;
                    continue;
                }
            }
            str = temp;
        }
        return str;
    }
};

int main(void)
{
    Solution su;
    string result = su.countAndSay(20);
    cout << result << endl;
    return 0;
}
